<template>
	<n-card
		title="欢迎登录数字实验教学系统!"
		:style="{ textAlign: 'center', marginTop: '20px', fontSize: '23px' }"
	>
		<div v-if="userStore.userInfo.role == '1'">
			<!-- <el-select
				v-model="value"
				value-key="id"
				placeholder="请选择学期"
				@change="selectchange"
				size="large"
			>
				<el-option
					v-for="item in options"
					:key="item.id"
					:label="item.academicYear + item.term"
					:value="item"
				/> </el-select
			><br /> -->
			<!-- 当前学期:{{ value ? value.academicYear + value.term : '未选择' }} -->
			当前学期:{{ value }}
		</div>

		<n-card
			title="您当前登录类型"
			hoverable
			:style="{ width: '200px', fontSize: '14px' }"
			class="login-type"
		>
			{{ role }}
			{{ userStore.userInfo.username }}
		</n-card>
		<n-card
			hoverable
			:style="{ width: '200px', marginTop: '20px', color: '#f4235f' }"
		>
			{{ mes }}
		</n-card>
	</n-card>
</template>
<script setup lang="ts">
//@ts-nocheck
import { useGlobalStore } from '../../store/GlobalStore'
import { GetSemester } from '../../api/request'
const userStore = useGlobalStore()
userStore.userInfo.semesterid = 2
let role = ref<any>('')
let mes = ref<any>('')
const jwtToken = localStorage.getItem('jwtToken')
if (userStore.userInfo.role == '2') {
	role = '学生用户'
	mes = '如果有问题请联系老师'
} else if (userStore.userInfo.role == '1') {
	role = '教师用户'
	mes = '老师您好'
} else if (userStore.userInfo.role == '3') {
	role = '管理员用户'
	mes = ''
}
const value = ref('')
const options = ref([])
const selectchange = (e) => {
	userStore.userInfo.semesterid = e.id
	console.log(userStore.userInfo.semesterid)
}
onMounted(async () => {
	let result = await GetSemester(jwtToken)
	//  console.log("Semester result",result.data.data);
	console.log('学期', result.data.data[0].term)
	value.value = result.data.data[0].term
	//  options.value=result.data.data
})
</script>

<style lang="less" scoped>
:deep(.n-card-header__main) {
	font-size: 20px;
}

.example-showcase .el-dropdown-link {
	cursor: pointer;
	color: var(--el-color-primary);
	display: flex;
	align-items: center;
}
</style>
